home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1991 …esperately Seeking Seven / Desperately Seeking Seven.2mg / Dev.CD.8 / Essentials / Tools / DTS.Samples / SC16Aware / Aware.c next >
Encoding:
C/C++ Source or Header  |  1990-05-25  |  3.4 KB  |  80 lines  |  [04] ASCII Text (0x0000)

  1. /*
  2.     Aware.c -- Version 3.0 
  3.     by Mark Day
  4.     
  5.     Developer Technical Support Apple II Sample Code
  6.  
  7.     Copyright (c) 1990 by Apple Computer, Inc.
  8.     All Rights Reserved.
  9.  
  10.     This is a very simple program that shows how to use the "@" prefix
  11.     and class 1 Open to be network aware.  When it starts up, it gets
  12.     the date/time it was last run from a configuration file.  When it
  13.     quits, it updates that last run time in the configuration file.
  14.     There are menu items to allow you to force the configuration to be
  15.     loaded and saved.  The last run time is displayed as part of the
  16.     about box.
  17.     
  18.     The "@" prefix is the name of the directory where configuration
  19.     information can be stored.  Its actual contents depend on where
  20.     the application was launched from.  If it was launched from a
  21.     non-AppleShare disk, it will be set to the directory containing
  22.     the application (the same as prefix "1").  If it was launched
  23.     from an AppleShare disk, it will be set to that user's folder on
  24.     the user volume of the file server (if there is no user volume
  25.     online, it will revert to the directory containing the application).
  26.     
  27.     This method is useful for saving configuration information, defaults,
  28.     or preferences on a per-user name basis.  Note that if several people
  29.     are logged on to the same server as the same user name, and launch
  30.     the application from a server, they will all access the same
  31.     configuration file (even though you use the "@" prefix).  It is up
  32.     to the users to log on with different names if they want to
  33.     personalize their configuration/defaults/preferences.
  34. */
  35.  
  36. #include <types.h>          /* {CIIGSIncludes}types.h */
  37. #include <quickdraw.h>      /* {CIIGSIncludes}quickdraw.h */
  38. #include <locator.h>        /* {CIIGSIncludes}locator.h */
  39.  
  40. /*
  41.     Here is the main program.  It's really pretty simple.  It
  42.     starts up the tools, creates the menus, loads the configuration
  43.     data, puts up the about box, and falls into the main event loop.
  44. */
  45. main()
  46. {
  47.     Ref     initRef;        /* This holds the reference to the startstop record */
  48.  
  49.     /*  Note: StartUpTools starts up the resource manager and opens
  50.         the application's resource fork as read-only.  This is the
  51.         safe, network aware way to do it.  You can always open it for
  52.         read/write yourself, but at the expense of extra code and not
  53.         being network aware. */
  54.         
  55.     /* Startup the tools using the new toolbox call */
  56.     initRef = StartUpTools(_ownerid, refIsResource, 0x0001L);
  57.  
  58.     /* Remember, (!_toolErr) means (if no error returned by the tool) */
  59.     if (!_toolErr) {
  60.     
  61.         /* Init the menus, the cursor, and global variables. */
  62.         setupMenus();       /* Set up menus */
  63.         InitCursor();       /* Make cursor show ready */
  64.         InitGlobals();      /* Set up global variables */
  65.         
  66.         /*  Here, load the configuration information for this user.
  67.             This is done now so that it is available for the about
  68.             box which is displayed at startup. */
  69.         
  70.         loadConfig();       /* Load configuration options */
  71.         doAboutItem();      /* Put up the about box */
  72.         
  73.         mainEvent();        /* Use application */
  74.     }
  75.  
  76.     /*  The user has quit the application (or it couldn't start
  77.         up the tools properly), so shut down the tools and exit. */
  78.     ShutDownTools(refIsHandle, initRef);
  79. }
  80.